#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    setMinimumSize(300,500);
    setMaximumSize(300,500);
    setWindowTitle("vChat");
    setWindowIcon(QIcon(":/images/title.png"));

    //设置到核心部件
    _loginDialog = new LoginDialog(this);
    setCentralWidget(_loginDialog);
    //_loginDialog->show();

    //创建注册信号与页面切换
    connect(_loginDialog, &LoginDialog::switchRegister,this, &MainWindow::SlotSwitchReg);
    _registerDialog = new RegisterDialog(this);

    //设置窗口嵌入
    _loginDialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
    _registerDialog->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
    _registerDialog->hide();
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::SlotSwitchReg()
{
    setCentralWidget(_registerDialog);
    _loginDialog->hide();
    _registerDialog->show();
}



